--============================================================= -- -- FUNCTIONS FOR DIALOGS ON ESCAPE (CORDON) MAP -- CoC 1.3.11 -- -- Modified by: DoctorX -- Last revised: March 18, 2016 -- --============================================================= -- ------------------------------------------------------------------------------------------------ -- FANATIC- function esc_2_12_stalker_fanat_about_quest(a,b) local npc = dialogs.who_is_npc(a,b) if (npc:has_info("npcx_is_companion") == true) then return false end return xr_conditions.has_task_not_completed(nil,nil,{"esc_m_trader_task_1"}) end function actor_dont_has_esc_m_trader_task_2(a,b) return not xr_conditions.has_task_not_completed(nil,nil,{"esc_m_trader_task_1"}) end function actor_has_esc_m_trader_task_2(a,b) return xr_conditions.has_task_not_completed(nil,nil,{"esc_m_trader_task_1"}) end function set_esc_2_12_stalker_fanat_as_companion(a,b) local npc = dialogs.who_is_npc(a,b) local squad = get_object_squad(npc) if not (squad) then return end for k in squad:squad_members() do local npc = k.id and (db.storage[k.id] and db.storage[k.id].object or level.object_by_id(k.id)) if (npc) then se_save_var(k.id,k.object:name(),"companion",true) se_save_var(k.id,k.object:name(),"companion_cannot_dismiss",true) se_save_var(k.id,k.object:name(),"companion_cannot_teleport",true) axr_companions.setup_companion_logic(npc,db.storage[k.id],false,true) end end end -- ------------------------------------------------------------------------------------------------ -- NIMBLE- function actor_has_mar_base_owl_stalker_trader_task_1_pda(a,b) return db.actor:object("mar_base_owl_stalker_trader_task_1_pda") ~= nil or false end -- xQd function actor_has_mar_base_owl_stalker_trader_warfare_task_1_pda(a,b) local tm = task_manager.get_task_manager() local task_info = tm.task_info return db.actor:object("mar_base_owl_stalker_trader_task_1_pda") ~= nil and task_info["sim_default_csky_trader_task_1"] or false end -- xQd end function actor_dont_has_mar_base_owl_stalker_trader_task_1_pda(a,b) return db.actor:object("mar_base_owl_stalker_trader_task_1_pda") == nil or false end function mar_base_owl_stalker_trader_task_1_give_reward(a,b) --esc_2_12_stalker_nimble_mar_base_owl_stalker_trader_task_1 local itm = db.actor:object("mar_base_owl_stalker_trader_task_1_pda") local npc = dialogs.who_is_npc(a,b) dialogs.relocate_item_section(npc, "mar_base_owl_stalker_trader_task_1_pda", "out", 1) if (itm) then alife_release_id(itm:id()) end --xQd local tm = task_manager.get_task_manager() local task_info = tm.task_info if (task_info) then if (task_info["mar_base_owl_stalker_trader_task_1"]) then task_manager.get_task_manager():set_task_completed("mar_base_owl_stalker_trader_task_1") elseif (task_info["sim_default_csky_trader_task_1"]) then task_manager.get_task_manager():set_task_completed("sim_default_csky_trader_task_1") end end --xQd end end ------------------------------------------------------------------------------ nimble_trade_instead = false esc_2_12_buy_item_table = nil item_count_by_category = nil esc_2_12_costs_table = nil local nimble_max_items = 0 function init_nimble_tables() if (esc_2_12_buy_item_table) then return end esc_2_12_costs_table = {} item_count_by_category = {} esc_2_12_buy_item_table = {} local ini = ini_file("plugins\\nimble_orders.ltx") nimble_trade_instead = ini:r_bool_ex("settings","nimble_trade_instead",false) nimble_max_items = ini:r_float_ex("settings","item_count") or 0 for i=1,nimble_max_items do item_count_by_category[i] = ini:r_float_ex("item_count","category_"..i) or 1 local str = ini:r_string_ex("costs_table","category_"..i) or "700, 1400, 2800" local t = parse_names(str) esc_2_12_costs_table[i] = {} esc_2_12_costs_table[i].prepay_agreed = tonumber(t[1]) or 700 esc_2_12_costs_table[i].prepay_refused = tonumber(t[2]) or 1400 esc_2_12_costs_table[i].cost = tonumber(t[3]) or 2800 esc_2_12_buy_item_table[i] = {} local sec = "buy_item_table_"..i local count = ini:line_count(sec) t = empty_table(t) for n=0,count-1 do local result, id, value = ini:r_line(sec, n, "", "") local item_list = value and value ~= "" and str_explode(value,",") or {} table.insert(item_list,id) t[#t+1] = {item=item_list} end esc_2_12_buy_item_table[i] = t end --utils_data.print_table(esc_2_12_buy_item_table,"nimble") end function nimble_can_trade(a,b) init_nimble_tables() return nimble_trade_instead == true end function nimble_cant_trade(a,b) return not nimble_can_trade() end function esc_2_12_randomize_item(first_speaker, second_speaker) init_nimble_tables() for i = 1,nimble_max_items do if has_alife_info("esc_2_12_processing_category_"..tostring(i)) then local esc_2_12_available_items_table = {} for j = 1, item_count_by_category[i] do if not has_alife_info("esc_2_12_done_item_"..tostring(i).."_"..tostring(j)) then esc_2_12_available_items_table[#esc_2_12_available_items_table+1] = j end end give_info("esc_2_12_ordered_item_"..tostring(i).."_"..tostring(esc_2_12_available_items_table[math.random(1,#esc_2_12_available_items_table)])) end end end function esc_2_12_give_prepay(first_speaker, second_speaker) init_nimble_tables() for i = 1,nimble_max_items do if has_alife_info("esc_2_12_processing_category_"..tostring(i)) then if not has_alife_info("esc_2_12_order_refused") then dialogs.relocate_money_from_actor(first_speaker, second_speaker, esc_2_12_costs_table[i].prepay_agreed) return end dialogs.relocate_money_from_actor(first_speaker, second_speaker, esc_2_12_costs_table[i].prepay_refused) return end end end function esc_2_12_has_prepay(first_speaker, second_speaker) init_nimble_tables() for i = 1,nimble_max_items do if has_alife_info("esc_2_12_processing_category_"..tostring(i)) then if not has_alife_info("esc_2_12_order_refused") then return db.actor:money() >= esc_2_12_costs_table[i].prepay_agreed end return db.actor:money() >= esc_2_12_costs_table[i].prepay_refused end end end function esc_2_12_hasnt_prepay(first_speaker, second_speaker) return not esc_2_12_has_prepay(first_speaker, second_speaker) end function esc_2_12_buy_item(first_speaker, second_speaker) init_nimble_tables() for i = 1,nimble_max_items do if has_alife_info("esc_2_12_processing_category_"..tostring(i)) then for j = 1,#esc_2_12_buy_item_table[i] do if has_alife_info("esc_2_12_ordered_item_"..tostring(i).."_"..tostring(j)) then for k,v in pairs(esc_2_12_buy_item_table[i][j].item) do dialogs.relocate_item_section_to_actor(first_speaker, second_speaker,v) end dialogs.relocate_money_from_actor(first_speaker, second_speaker, esc_2_12_costs_table[i].cost) disable_info("esc_2_12_processing_category_"..tostring(i)) disable_info("esc_2_12_ordered_item_"..tostring(i).."_"..tostring(j)) give_info("esc_2_12_done_item_"..tostring(i).."_"..tostring(j)) break end end local category_finishing = true for j = 1,#esc_2_12_buy_item_table[i] do if not has_alife_info("esc_2_12_done_item_"..tostring(i).."_"..tostring(j)) then category_finishing = false break end end if category_finishing == true then give_info("esc_2_12_finishing_category_"..tostring(i)) end return end end end function esc_2_12_refuse_item(first_speaker, second_speaker) init_nimble_tables() for i = 1,nimble_max_items do if has_alife_info("esc_2_12_processing_category_"..tostring(i)) then for j = 1,#esc_2_12_buy_item_table[i] do if has_alife_info("esc_2_12_ordered_item_"..tostring(i).."_"..tostring(j)) then disable_info("esc_2_12_processing_category_"..tostring(i)) disable_info("esc_2_12_ordered_item_"..tostring(i).."_"..tostring(j)) give_info("esc_2_12_done_item_"..tostring(i).."_"..tostring(j)) break end end local category_finishing = true for j = 1,#esc_2_12_buy_item_table[i] do if not has_alife_info("esc_2_12_done_item_"..tostring(i).."_"..tostring(j)) then category_finishing = false break end end if category_finishing == true then give_info("esc_2_12_finishing_category_"..tostring(i)) end return end end end function esc_2_12_has_item_cost(first_speaker, second_speaker) init_nimble_tables() for i = 1,nimble_max_items do if has_alife_info("esc_2_12_processing_category_"..tostring(i)) then return db.actor:money() >= esc_2_12_costs_table[i].cost end end return false end function esc_2_12_hasnt_item_cost(first_speaker, second_speaker) return not esc_2_12_has_item_cost(first_speaker, second_speaker) end